<?php

require_once('../include/GeneralTop.php');
require('../include/class/db.php');
require('../include/class/pagination.php');
require('../include/simpleHeader.php');


$id  = "-1";
if (isset($_GET['Id'])) {
  $id  = $_GET['Id'];
}

$db = new db;
if ( isset($_GET['Id']) && isset($_GET['adopt']) && $_GET['adopt'] == 'true')
{
	$updateSQL  = "UPDATE pet_info SET PIsAdopt =0 WHERE PAId = ".$_GET['Id'];
    $Result1 = $db->query($updateSQL);
}

$sql = sprintf("SELECT * FROM pet_info WHERE PAId = %s", GetSQLValueString($id , "int"));
$res = $db->query($sql);
$row = $db->fetch($res);

?>

<body topmargin="0" leftmargin="0">
<table width="777" border="0" align="left" cellpadding="0" cellspacing="0" valign="top">
  <tr>
    <td width="777" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="51" valign="top" background="../images/fen_09.gif"><table width="95%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="16">&nbsp;</td>
            </tr>
          </table>
          <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="14"><img src="../images/fen_12.gif" width="7" height="29"></td>
              <td width="405"><span class="font_16px_black_B"><?php echo $row['PAPetName']; ?></span></td>
              <td width="15">&nbsp;</td>
              <td width="299" align="right" class="font_12px_gray"><a href="javascript:history.go(-1);" class="gray_12px">[<?php echo TEXT_BACK?>]</a></td>
              </tr>
          </table></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="1" bgcolor="#767676"></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="8"></td>
        </tr>
      </table>
      <table id="table1" width="95%" border="0" align="center" cellpadding="5" cellspacing="0" class="table_border_grey" style="margin-bottom:10px;">
  <tr>
    <td align="right" width="20%" class="font_12px_gray"><?php echo TEXT_TYPE; ?></td>
    <td align="left" width="80%" class="font_12px_gray"><?php echo getPetType($row['PType']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_NAME; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['PAPetName']; ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_VARIETY; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['PVariety']; ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_GENDER; ?></td>
   <td align="left" class="font_12px_gray"><?php echo getGender($row['PGender']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_ORIGIN; ?></td>
   <td align="left" class="font_12px_gray"><?php echo getOrigin($row['pet_origin']); ?></td>
  </tr>
  <?php
  if(1 === (int)$row['pet_origin']) {
  ?>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_SAVE_DATE; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['PADate']; ?></td>
  </tr>
  <?php
  }
  else 
  {
  ?>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_ABANDON_REASON; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['PAMemo']; ?></td>
  </tr>
  <?php
  }
  ?>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_AGE_ABOUT; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['age']; ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_SP_SIT; ?></td>
   <td align="left" class="font_12px_gray"><?php echo getSpay($row['spay_YN']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_SP_DATE; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['spay_date']; ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_VA_SIT; ?></td>
   <td align="left" class="font_12px_gray"><?php echo getVaccinate($row['vaccinated_YN']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_VA_DATE; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['vaccinated_date']; ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_DI_SIT; ?></td>
   <td align="left" class="font_12px_gray"><?php echo getDewormin($row['dewormIn_YN']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_DI_DATE; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['dewormInDate']; ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_DE_SIT; ?></td>
   <td align="left" class="font_12px_gray"><?php echo getDewormext($row['dewormExt_YN']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_DE_DATE; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $row['dewormExtDate']; ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_HEALTHINFO; ?></td>
   <td align="left" class="font_12px_gray"><?php echo nl2br($row['Pet_healthinfo']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_OTHERINFO; ?></td>
   <td align="left" class="font_12px_gray"><?php echo nl2br($row['Pet_otherinfo']); ?></td>
  </tr>
  <tr>
   <td align="right" class="font_12px_gray"><?php echo TEXT_STORY; ?></td>
   <td align="left" class="font_12px_gray"><?php echo nl2br($row['story']); ?></td>
  </tr>
  <?php
  /*
  if('N' != $row['Doctor_check'] && 3 != (int)$row['Doctor_check']) {
      $doctor_check = getDoctorCheck($row['Doctor_check']).' '.$row['Doctor_check'];
  }
  else {
  	  $doctor_check = getDoctorCheck($row['Doctor_check']);
  }
  */
  $doctor_check = getDoctorCheck($row['Doctor_check']);

  ?>
  <tr>
   <td align="right" class="font_12px_gray" nowrap><?php echo TEXT_DOCTOR_CHECK; ?></td>
   <td align="left" class="font_12px_gray"><?php echo $doctor_check; ?></td>
  </tr>  
  <tr>
    <td>&nbsp;</td>
    <td align="left" valign="top" class="font_12px_gray">
    <?php
    if('' != $row['PPhoto_main'] && NULL != $row['PPhoto_main']) {
    ?>
    <img class="img_border" src="<?php echo IMAGES_PET_FOLDER.$row['PPhoto_main']; ?>" border="0" class="img_border">
    <?php
    }
    if('' != $row['photo_detail1'] && NULL != $row['photo_detail1']) {
    ?>
    <img class="img_border" src="<?php echo IMAGES_PET_FOLDER.$row['photo_detail1']; ?>" border="0" class="img_border">
    <?php
    }
    if('' != $row['photo_detail2'] && NULL != $row['photo_detail2']) {
    ?>
    <img class="img_border" src="<?php echo IMAGES_PET_FOLDER.$row['photo_detail2']; ?>" border="0" class="img_border">
    <?php
    }
    ?>
    </td>
  </tr>
  <!--
  <tr>
    <td>&nbsp;</td>
    <td align="left">
      <input type="button" id="button" name="button" value="<?php echo TEXT_PET_ADOPT?>" onclick="show_contact_info();"/>
    </td>   
  </tr>
  <tr id="rescuer_name" style="display:none">
    <td align="right" class="font_12px_gray"><?php echo TEXT_RESCUER_NAME?></td>
    <td align="left" class="font_12px_gray"><?php echo $row['Rescuer_name']?></td>
  </tr>
  <tr id="rescuer_sex" style="display:none">
    <td align="right" class="font_12px_gray"><?php echo TEXT_RESCUER_SEX?></td>
    <td align="left" class="font_12px_gray"><?php echo $row['Rescuer_sex']?></td>
  </tr>
  <tr id="rescuer_phone" style="display:none">
    <td align="right" class="font_12px_gray"><?php echo TEXT_RESCUER_PHONE?></td>
    <td align="left" class="font_12px_gray"><?php echo $row['Rescuer_phone']?></td>
  </tr>
  <tr id="rescuer_address" style="display:none">
    <td align="right" class="font_12px_gray"><?php echo TEXT_RESCUER_ADDRESS?></td>
    <td align="left" class="font_12px_gray"><?php echo $row['Rescuer_address']?></td>
  </tr>
  <tr id="contact_way" style="display:none">
    <td align="right" class="font_12px_gray"><?php echo TEXT_RESCUER_CONTACT_WAY?></td>
    <td align="left" class="font_12px_gray"><?php echo $row['contact_way'] === NULL ? '&nbsp;' : $row['contact_way']?></td>
  </tr>
</table>
    <tr><td>&nbsp;</td></tr>
	  <tr><td>&nbsp;</td></tr>
	  <tr><td>&nbsp;</td></tr>
	  <tr><td>&nbsp;</td></tr>
	  <tr><td>&nbsp;</td></tr>
	  <tr><td>&nbsp;</td></tr>
    </td>
  </tr>
  -->
</table>                       
</body>
</html>

<script language="javascript">
function show_contact_info() {
	document.getElementById('rescuer_name').style.display = '';
	document.getElementById('rescuer_sex').style.display = '';
	document.getElementById('rescuer_phone').style.display = '';
	document.getElementById('rescuer_address').style.display = '';
	document.getElementById('contact_way').style.display = '';
}
</script>